<?php
defined('_JEXEC') or die('Restricted access');
$img_dir = JPATH_SITE.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'fileupload'.DIRECTORY_SEPARATOR;
$img_path = JURI::root(true).'/images/fileupload/';
$title = ($this->id)?"Sửa thông tin máy":"Thêm máy vào kho";

$cache_dir = JPATH_COMPONENT.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
$cache_filename_mayphoto = $cache_dir."mayphoto.php";
if(JFile::exists($cache_filename_mayphoto))
{
	include($cache_filename_mayphoto);
	$cache_data_mayphoto = $cache_mayphoto;
}else $cache_data_mayphoto = array();

?>
<div class='tab_content' id="tab_create_inventory">
	<div class='container-fluid container_root margin10'>
		<div class='row-fluid'>
			<div class='widget widget-padding span12'>
				<div class='widget-header'>
					<i class="icon-plus"></i>
					<h5><?php echo $title ?></h5>
				</div>
				<div class='widget-body'>
								
					<form class='form' id="form_create_inventory" method="post" action="index.php">
						<div class='row-fluid'>
							<div class='span12'>
								<button type="submit" class='btn btn-primary'>
									<i class='icon-ok icon-white'></i>
									<?php echo JText::_("COM_KETNOI_SAVEBTN") ?>
								</button>
							</div>
						</div>
						
						<div class="row-fluid margin10">
							<div class='span12'>
								<div class="row-fluid">
									<div class="span4">
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Serial
												<em>*</em>
											</label>
					                        <div class="controls row-fluid">
					                            <input type="text" name="serial" required class="span12" value="<?php echo $this->row->serial ?>"/>
					                        </div>
				                        </div>
									</div>
									
									<div class="span4">
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Chọn máy
												<em>*</em>
											</label>
					                        <div class="controls row-fluid chosen_multiple chosen_table chosen_quickcreate chosen_selectone">
					                            <select  data-placeholder="Chọn máy" id="machine" multiple name="machine_id">
					                            	<?php foreach ($cache_data_mayphoto as $machine): ?>
					                            		<?php $selected = $machine["id"] == $this->row->machine_id?"selected":"" ?>
					                            		<option <?= $selected ?> data-thang='<?php echo $machine["sothangbaohanh"] ?>' data-dungluong='<?php echo $machine["sodungluongbaohanh"] ?>' value="<?php echo $machine["id"] ?>" data-ten="<?php echo $machine["ten"] ?>" data-ma="<?php echo $machine["ma"] ?>">
					                            			<?php echo $machine["ma"] ?> - <?php echo $machine["ten"] ?> 
					                            		</option>
					                            	<?php endforeach; ?>
					                            </select>
					                            <a class='btn btn-info fix-btn' onclick='showModalCreateMayPhoto("machine")'>
													<i class='icon icon-plus'></i>
												</a>
					                        </div>
				                        </div>
									</div>
									
									<div class="span4">
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Nhà cung cấp
												<em>*</em>
											</label>
					                        <div class="controls row-fluid chosen_multiple chosen_table chosen_quickcreate">
					                            <select multiple data-placeholder="Chọn nhà cung cấp" id="nhacungcap" name="vendor_id">
					                            	<?php foreach ($this->vendor as $vendor): ?>
					                            		<?php $selected = $vendor->id == $this->row->vendor_id?"selected":"" ?>
					                            		<option <?= $selected ?> value="<?php echo $vendor->id ?>" data-ten="<?php echo $vendor->ten ?>" data-ma="<?php echo $vendor->ma ?>">
					                            			<?php echo $vendor->ma ?> - <?php echo $vendor->ten ?>
					                            		</option>
					                            	<?php endforeach; ?>
					                            </select>
					                            <a class='btn btn-info fix-btn' onclick='showModalCreateVendor("nhacungcap")'>
													<i class='icon icon-plus'></i>
												</a>
					                        </div>
				                        </div>
									</div>
								</div>
							</div>
						</div>
						
						<input type="hidden" name="option" value="com_ketnoi" />
						<input type="hidden" name="view" value="inventory" />
						<input type="hidden" name="task" value="inventory.save" />
						<input type="hidden" name="layout" value="create" />
						<input type="hidden" name="tmpl" value="raw" />
						<input type="hidden" name="quickcreate" value="<?= JRequest::getVar("quickcreate",0) ?>" />
						<input type="hidden" name="client_update" value="<?= JRequest::getVar("client_update","") ?>" />
						<?php if($this->id): ?>
						<input type="hidden" name="id" value="<?= $this->id ?>" />
						<?php endif; ?>
					</form>
				</div>
				
			</div>
		</div>
	</div>
</div>

